package com.acoreful.bootsample.config;

import org.springframework.cache.Cache;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.extern.slf4j.Slf4j;
@Configuration
@Slf4j
public class RedisCacheConfig extends CachingConfigurerSupport {
	
	
	@Bean
	@Override
	public CacheErrorHandler errorHandler() {
		CacheErrorHandler cacheErrorHandler = new CacheErrorHandler() {

			@Override
			public void handleCacheGetError(RuntimeException exception, Cache cache, Object key) {
				// TODO Auto-generated method stub
				log.error("[ERROR]======key:{},exception:{}",key,exception);
			}

			@Override
			public void handleCachePutError(RuntimeException exception, Cache cache, Object key, Object value) {
				// TODO Auto-generated method stub
				log.error("[ERROR]======key:{},exception:{}",key,exception);
			}

			@Override
			public void handleCacheEvictError(RuntimeException exception, Cache cache, Object key) {
				// TODO Auto-generated method stub
				log.error("[ERROR]======key:{},exception:{}",key,exception);
			}

			@Override
			public void handleCacheClearError(RuntimeException exception, Cache cache) {
				// TODO Auto-generated method stub
				log.error("[ERROR]======exception:{}",exception,exception);
			}  
        };  
        return cacheErrorHandler;
	}
}
